<?php

use yii\helpers\Inflector;
use yii\helpers\StringHelper;

/* @var $this yii\web\View */
/* @var $generator yii\gii\generators\crud\Generator */

/* @var $model \yii\db\ActiveRecord */
$model = new $generator->modelClass();
$safeAttributes = $model->safeAttributes();
if (empty($safeAttributes)) {
    $safeAttributes = $model->attributes();
}
/* @var $ajaxOptions array */

echo "<?php\n";
?>

use yii\helpers\Html;
use yak\layui\widgets\form\ActiveForm;

/* @var $this yii\web\View */
/* @var $model <?= ltrim($generator->modelClass, '\\') ?> */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-form form-block">

    <?= "<?php " ?>$form = ActiveForm::begin([ 'ajaxOptions' => $ajaxOptions ]); ?>

    <?php foreach ($generator->getColumnNames() as $attribute) {
        if (in_array($attribute, $safeAttributes)) {
            echo "    <?= " . $generator->generateActiveField($attribute) . " ?>\n\n";
        }
    } ?>
    <div class="layui-form-item layui-input-block">
        <?= "<?= " ?>Html::submitButton(<?= $generator->generateString('立即提交') ?>, [
        'class' => 'layui-btn', 'lay-submit' => true, 'lay-filter' => '_SUBMIT_FORM'
        ]) ?>
    </div>

    <?= "<?php " ?>ActiveForm::end(); ?>

</div>
